package nancal.mp.db.mongo.table

import java.io.*
import nbcp.base.db.*
import nbcp.base.comm.*
import nbcp.base.extend.*
import nbcp.base.enums.*
import nbcp.base.utils.*
import nbcp.myoql.db.*
import nbcp.myoql.db.comm.*
import nbcp.myoql.db.enums.*
import nbcp.myoql.db.mongo.*
import nbcp.myoql.db.mongo.base.*
import nbcp.myoql.db.mongo.component.*
import org.slf4j.LoggerFactory
import org.springframework.stereotype.*


@Component("mongo.admin")
@MetaDataGroup(DatabaseEnum.Mongo, "admin")
class AdminGroup : IDataGroup {
    override fun getEntities(): Set<BaseMetaData<out Any>> = setOf(adminLoginUser, adminMenu, adminPermissionApi, adminPermissionPage, adminPermissionPageAction, adminRole, adminUser, workBill)



    val adminLoginUser get() = AdminLoginUserEntity();



    /**
     * 菜单
     */
    val adminMenu get() = AdminMenuEntity();



    /**
     * 权限接口
     */
    val adminPermissionApi get() = AdminPermissionApiEntity();



    /**
     * 权限页面定义
     */
    val adminPermissionPage get() = AdminPermissionPageEntity();



    /**
     * 权限页面按钮
     */
    val adminPermissionPageAction get() = AdminPermissionPageActionEntity();



    /**
     * 后台角色
     */
    val adminRole get() = AdminRoleEntity();




    val adminUser get() = AdminUserEntity();




    val workBill get() = WorkBillEntity();



    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    @nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""id"""), unique = true)
    @nbcp.base.db.annotation.DbEntityIndexes(value = arrayOf(nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""loginName"""), unique = true)))
    class AdminLoginUserEntity(collectionName: String = "adminLoginUser") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminLoginUser>(nancal.mp.db.mongo.entity.admin.AdminLoginUser::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val errorLoginTimes = MongoColumnName("errorLoginTimes")

        /**
         * google验证器密钥
         */
        @nbcp.base.db.annotation.Cn(value = """google验证器密钥""") 
        val totpKey = MongoColumnName("totpKey")

        val mfa1 = MongoColumnName("mfa1")

        val mfa1ExpireAt = MongoColumnName("mfa1ExpireAt")

        /**
         * 登录名
         */
        @nbcp.base.db.annotation.Cn(value = """登录名""") 
        val loginName = MongoColumnName("loginName")

        /**
         * 登录手机
         */
        @nbcp.base.db.annotation.Cn(value = """登录手机""") 
        val mobile = MongoColumnName("mobile")

        /**
         * 登录邮箱
         */
        @nbcp.base.db.annotation.Cn(value = """登录邮箱""") 
        val email = MongoColumnName("email")

        /**
         * 密码
         */
        @nbcp.base.db.annotation.Cn(value = """密码""") 
        val password = MongoColumnName("password")

        /**
         * 最后登录时间
         */
        @nbcp.base.db.annotation.Cn(value = """最后登录时间""") 
        val lastLoginAt = MongoColumnName("lastLoginAt")

        /**
         * 是否已锁定
         */
        @nbcp.base.db.annotation.Cn(value = """是否已锁定""") 
        val isLocked = MongoColumnName("isLocked")

        /**
         * 锁定详情
         */
        @nbcp.base.db.annotation.Cn(value = """锁定详情""") 
        val lockedRemark = MongoColumnName("lockedRemark")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

        fun queryByLoginName(loginName: String): MongoQueryClip<AdminLoginUserEntity, nancal.mp.db.mongo.entity.admin.AdminLoginUser> {
            return this.query().where { it.loginName mongoEquals loginName }
        }


        fun deleteByLoginName(loginName: String): MongoDeleteClip<AdminLoginUserEntity> {
            return this.delete().where { it.loginName mongoEquals loginName }
        }

        fun updateByLoginName(loginName: String): MongoUpdateClip<AdminLoginUserEntity, nancal.mp.db.mongo.entity.admin.AdminLoginUser> {
            return this.update().where { it.loginName mongoEquals loginName }
        }
        
        


        fun queryById(id: String): MongoQueryClip<AdminLoginUserEntity, nancal.mp.db.mongo.entity.admin.AdminLoginUser> {
            return this.query().where { it.id mongoEquals id }
        }


        fun deleteById(id: String): MongoDeleteClip<AdminLoginUserEntity> {
            return this.delete().where { it.id mongoEquals id }
        }

        fun updateById(id: String): MongoUpdateClip<AdminLoginUserEntity, nancal.mp.db.mongo.entity.admin.AdminLoginUser> {
            return this.update().where { it.id mongoEquals id }
        }
        
        

    }

    /**
     * 菜单
     */
    @nbcp.base.db.annotation.Cn(value = """菜单""")
    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    class AdminMenuEntity(collectionName: String = "adminMenu") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminMenu>(nancal.mp.db.mongo.entity.admin.AdminMenu::class.java, collectionName) {

        val id = MongoColumnName("_id")

        /**
         * 菜单名称
         */
        @nbcp.base.db.annotation.Cn(value = """菜单名称""") 
        val name = MongoColumnName("name")

        /**
         * 资源编码
         */
        @nbcp.base.db.annotation.Cn(value = """资源编码""") 
        val code = MongoColumnName("code")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

        /**
         * 菜单链接
         */
        @nbcp.base.db.annotation.Cn(value = """菜单链接""") 
        val url = MongoColumnName("url")

        /**
         * class
         */
        @nbcp.base.db.annotation.Cn(value = """class""") 
        val css = MongoColumnName("css")

        /**
         * 排序
         */
        @nbcp.base.db.annotation.Cn(value = """排序""") 
        val sort = MongoColumnName("sort")

        val parent = IdNameMeta("parent")

    }

    /**
     * 权限接口
     */
    @nbcp.base.db.annotation.Cn(value = """权限接口""")
    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    class AdminPermissionApiEntity(collectionName: String = "adminPermissionApi") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminPermissionApi>(nancal.mp.db.mongo.entity.admin.AdminPermissionApi::class.java, collectionName) {

        val id = MongoColumnName("_id")

        /**
         * 接口名称
         */
        @nbcp.base.db.annotation.Cn(value = """接口名称""") 
        val name = MongoColumnName("name")

        /**
         * 地址,格式[方法]@/url
         */
        @nbcp.base.db.annotation.Cn(value = """地址,格式[方法]@/url""") 
        val url = MongoColumnName("url")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }

    /**
     * 权限页面定义
     */
    @nbcp.base.db.annotation.Cn(value = """权限页面定义""")
    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    class AdminPermissionPageEntity(collectionName: String = "adminPermissionPage") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminPermissionPage>(nancal.mp.db.mongo.entity.admin.AdminPermissionPage::class.java, collectionName) {

        val id = MongoColumnName("_id")

        /**
         * 页面名称
         */
        @nbcp.base.db.annotation.Cn(value = """页面名称""") 
        val name = MongoColumnName("name")

        /**
         * vue路由
         */
        @nbcp.base.db.annotation.Cn(value = """vue路由""") 
        val path = MongoColumnName("path")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }

    /**
     * 权限页面按钮
     */
    @nbcp.base.db.annotation.Cn(value = """权限页面按钮""")
    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    class AdminPermissionPageActionEntity(collectionName: String = "adminPermissionPageAction") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminPermissionPageAction>(nancal.mp.db.mongo.entity.admin.AdminPermissionPageAction::class.java, collectionName) {

        val id = MongoColumnName("_id")

        /**
         * 按钮名称
         */
        @nbcp.base.db.annotation.Cn(value = """按钮名称""") 
        val name = MongoColumnName("name")

        /**
         * 动作定义
         */
        @nbcp.base.db.annotation.Cn(value = """动作定义""") 
        val action = MongoColumnName("action")

        /**
         * 页面
         */
        @nbcp.base.db.annotation.Cn(value = """页面""") 
        val page = IdNamePathMeta("page")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }

    /**
     * 后台角色
     */
    @nbcp.base.db.annotation.Cn(value = """后台角色""")
    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    class AdminRoleEntity(collectionName: String = "adminRole") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminRole>(nancal.mp.db.mongo.entity.admin.AdminRole::class.java, collectionName) {

        val id = MongoColumnName("_id")

        /**
         * 角色名称
         */
        @nbcp.base.db.annotation.Cn(value = """角色名称""") 
        val name = MongoColumnName("name")

        /**
         * 允许的Api
         */
        @nbcp.base.db.annotation.Cn(value = """允许的Api""") 
        val permissionApis = IdNamePathMeta("permissionApis")

        /**
         * 授权的菜单
         */
        @nbcp.base.db.annotation.Cn(value = """授权的菜单""") 
        val menus = IdNamePathMeta("menus")

        /**
         * 允许的页面按钮权限
         */
        @nbcp.base.db.annotation.Cn(value = """允许的页面按钮权限""") 
        val pageActions = AdminPermissionPageActionMeta("pageActions")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    @nbcp.base.db.annotation.DbEntityIndexes(value = arrayOf(nbcp.base.db.annotation.DbEntityIndex(value = arrayOf("""loginName"""), unique = true)))
    class AdminUserEntity(collectionName: String = "adminUser") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.AdminUser>(nancal.mp.db.mongo.entity.admin.AdminUser::class.java, collectionName) {

        val id = MongoColumnName("_id")

        /**
         * 昵称
         */
        @nbcp.base.db.annotation.Cn(value = """昵称""") 
        val name = MongoColumnName("name")

        /**
         * 岗位
         */
        @nbcp.base.db.annotation.Cn(value = """岗位""") 
        val duty = MongoColumnName("duty")

        val isAdmin = MongoColumnName("isAdmin")

        val address = MongoColumnName("address")

        val roles = IdNameMeta("roles")

        /**
         * 登录名
         */
        @nbcp.base.db.annotation.Cn(value = """登录名""") 
        val loginName = MongoColumnName("loginName")

        /**
         * 手机号
         */
        @nbcp.base.db.annotation.Cn(value = """手机号""") 
        val mobile = MongoColumnName("mobile")

        /**
         * 电子邮件
         */
        @nbcp.base.db.annotation.Cn(value = """电子邮件""") 
        val email = MongoColumnName("email")

        /**
         * 头像
         */
        @nbcp.base.db.annotation.Cn(value = """头像""") 
        val logo = IdUrlMeta("logo")

        /**
         * 备注
         */
        @nbcp.base.db.annotation.Cn(value = """备注""") 
        val remark = MongoColumnName("remark")

        /**
         * 身份证
         */
        @nbcp.base.db.annotation.Cn(value = """身份证""") 
        val identityCard = IdentityCardDataMeta("identityCard")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

        fun queryByLoginName(loginName: String): MongoQueryClip<AdminUserEntity, nancal.mp.db.mongo.entity.admin.AdminUser> {
            return this.query().where { it.loginName mongoEquals loginName }
        }


        fun deleteByLoginName(loginName: String): MongoDeleteClip<AdminUserEntity> {
            return this.delete().where { it.loginName mongoEquals loginName }
        }

        fun updateByLoginName(loginName: String): MongoUpdateClip<AdminUserEntity, nancal.mp.db.mongo.entity.admin.AdminUser> {
            return this.update().where { it.loginName mongoEquals loginName }
        }
        
        

    }


    @org.springframework.data.mongodb.core.mapping.Document()
    @nbcp.base.db.annotation.DbEntityGroup(value = """admin""")
    class WorkBillEntity(collectionName: String = "workBill") :
        MongoBaseMetaCollection<nancal.mp.db.mongo.entity.admin.WorkBill>(nancal.mp.db.mongo.entity.admin.WorkBill::class.java, collectionName) {

        val id = MongoColumnName("_id")

        val corp = IdNameMeta("corp")

        val title = MongoColumnName("title")

        val content = MongoColumnName("content")

        val images = IdUrlMeta("images")

        val discussions = DiscussItemMeta("discussions")

        /**
         * 创建时间
         */
        @nbcp.base.db.annotation.Cn(value = """创建时间""") 
        val createAt = MongoColumnName("createAt")

        /**
         * 更新时间
         */
        @nbcp.base.db.annotation.Cn(value = """更新时间""") 
        val updateAt = MongoColumnName("updateAt")

    }

}

